//
// Created by 11197 on 25-5-12.
//

#include "StyleLoader.h"

#include <QMouseEvent>
#include <QFile>

std::unique_ptr<StyleLoader> StyleLoader::instance_ = nullptr;

StyleLoader::StyleLoader()
{

}

StyleLoader::~StyleLoader()
{

}

StyleLoader * StyleLoader::getInstance()
{
    static std::once_flag flag;
    std::call_once(flag, [&]() {
        instance_.reset(new StyleLoader());
    });
    return instance_.get();
}

void StyleLoader::loadStyle(const QString &filepath, QWidget *w)
{
    QFile file(filepath);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return; }
    QString qss = QString::fromUtf8(file.readAll().data());
    w->setStyleSheet(qss);
}


